package com.channelsharing.hongqu.portal.api.controller.groupbuy;

import com.channelsharing.common.entity.Paging;
import com.channelsharing.common.enums.BooleanEnum;
import com.channelsharing.common.enums.DelFlagEnum;
import com.channelsharing.hongqu.portal.api.controller.BaseController;
import com.channelsharing.hongqu.portal.api.entity.GoodsInfo;
import com.channelsharing.hongqu.portal.api.entity.GroupBuyProduct;
import com.channelsharing.hongqu.portal.api.enums.RoleType;
import com.channelsharing.hongqu.portal.api.service.GroupBuyService;
import com.channelsharing.pub.enums.ApproveStatus;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Api(value = "团购相关接口")
@RestController
@Validated
@RequestMapping("/v1/groupBuy/")
public class GroupBuyController extends BaseController {
    @Autowired
    private GroupBuyService groupBuyService;


    @ApiOperation(value = "获取所有团购产品")
    @GetMapping("all")
    public Paging<GroupBuyProduct> findPaging(@RequestParam(defaultValue = "0") Integer offset,
                                        @RequestParam(defaultValue = "10") Integer limit) {
        GroupBuyProduct entity = new GroupBuyProduct();
        entity.setOffset(offset);
        entity.setLimit(limit);
        return groupBuyService.findPaging(entity);

    }

    @ApiOperation(value = "获取单一团购产品")
    @GetMapping("{id}")
    public GroupBuyProduct findOne(@PathVariable Long id) {
        return groupBuyService.findOne(id);
    }


}
